package com.softer.ztb.common.util;


import java.io.PrintWriter;
import java.io.StringWriter;

/**
 * 异常转换成日志信息
 */
public final class ErrorToLogUtils {
    /**
     * 将异常转换成 logback 行信息
     * @param t 异常
     * @return str
     */
    public static String getTrace(Throwable t) {
        StringWriter stringWriter = new StringWriter();
        PrintWriter writer = new PrintWriter(stringWriter);
        t.printStackTrace(writer);
        StringBuffer buffer = stringWriter.getBuffer();
        return buffer.toString();
    }
}
